<?php
require_once '../lib/controller.php';

class action extends controller
{
	function do_get()
	{
		$this->view('www.addsite');
	}

	public function do_post()
	{
		$member = $this->module('biz.site');
		if( $member->add_site() )
		{
			$this->msg($member->msg, 0, 'addsite.php');
		}else{
			$this->msg($member->msg);
		}
	}

	function check_privileges()
	{
		if( ! isset($this->session['user_id']) )
		{
			return false;
		}else{
			return true;
		}
	}

	public function check_post()
	{
		if( strlen($this->post['site']) > 16 || strlen($this->post['site']) < 3 )
		{
			$this->msg('站点名称格式不正确');
			return false;
		}
		$tool = $this->module('lib.tool');
		if( ! $tool->check_url($this->post['url']) )
		{
			$this->msg('网址格式不正确');
			return false;
		}
		return true;
	}

}

$action = new action();
$action->run();
?>